1 using UnityEngine;
2
3 [RequireComponent(
typeof (PhotonView))]
4 public
class HighlightOwnedGameObj : Photon.MonoBehaviour
5 {
6     
public GameObject PointerPrefab;
7     
public float Offset = 0.5f;
8     
private Transform markerTransform;
9
10
11     
// Update is called once per frame
12     
private void Update()
13     {
14         
if (photonView.isMine)
15         {
16             
if (this.markerTransform == null)
17             {
18                 GameObject markerObject = (GameObject) GameObject.Instantiate(
this.PointerPrefab);
19                 markerObject.transform.parent = gameObject.transform;
20                 
this.markerTransform = markerObject.transform;
21             }
22
23             Vector3 parentPos = gameObject.transform.position;
24             
this.markerTransform.position = new Vector3(parentPos.x, parentPos.y + this.Offset, parentPos.z);
25             
this.markerTransform.rotation = Quaternion.identity;
26         }
27         
else if (this.markerTransform != null)
28         {
29             Destroy(
this.markerTransform.gameObject);
30             
this.markerTransform = null;
31         }
32     }
33 }


Update is called once per frame




Trò chơi Tic-Tac-Toe, game đánh caro full source code 53.544 lượt xem

Gõ tìm kiếm nhanh...